package BuddyTemplate;

/* Team Directories
 *
 * You are free to do whatever you want with this code. Frankly we don't give a damn.
 * 
 *  
 * Copyright GNU General Public License v3
 */

/*
 * QuestionLayer is simply a collection of Questions
 * 
 * The methods of this QuestionLayer are defined by both a state (the current question,
 * or variable QuestionAt) and the array of question. Each time nextQuestion is called,
 * the QuestionAt increases by one. Under no circumstances can QuestionAt decrease, 
 * or all hell will beak lose.
 * 
 * @author Gabriel
 * 
 */

import java.util.*;
import java.io.*; 
import javax.swing.*;

public class QuestionLayer implements Cloneable{

    ArrayList<Question<Object, Object>> QuestionCollection = new ArrayList<Question<Object, Object>>(); 
    int QuestionAt = 0;
    
    int iterator_QuestionAt = 0;
    
    // For now Question Collection will only Consist of String Objects
    
    public boolean isFinal(){
        
        // If we are at the last question, that is to say, the QuestionAt is equal to the
        // size of the Question
        
        if (QuestionAt == QuestionCollection.size()){
            return true;
        }
        
        else {
            return false;
        }
        
    }
    
    public void setQuestionAt(int x){
        
        QuestionAt = x;
        
    }
    
    public void addQuestion(Question NewQuestion){
        
        QuestionCollection.add(NewQuestion);
        
    }
    
    
    
    public Question nextQuestion(){

        String[] temp = new String[5];
        
        // Returns the next question
            
        if (QuestionAt < QuestionCollection.size()){
            
            // We increase QuestionAt by 1
            QuestionAt ++;
            
            // And then we return the current Question
            return QuestionCollection.get(QuestionAt-1);


        }
        
        else {
            
            // To avoid runtime errors, we simply return nothing. This means a default question
            // will be displayed
            
            return new Question<Object, Object>();
        
        }
        
    }
    
    public int CheckAnswer(ArrayList<Boolean> Choice)
    {        
        // Checks the answer of a particular question
        
        return QuestionCollection.get(QuestionAt-1).checkAnswers(Choice);
        
    }
    
    
    public int size(){
        
        // Returns the number of questions in the questionCollection
        
        return QuestionCollection.size();
        
    }
    
    
    
        
}
